Is amazing.
Key Reference: RMarkdown - The Definitive Guide
PDF Printing Setup: tinytex
Free-form text.
Make text bold.
Make text italics.
Make text bold + italics.
Talk about code - the tidyverse is awesome
Unordered List:
Item 1
Item 2
Ordered List:
First point
Second point
More points
This is Tab 1
This is Tab 2
Business Science Logo
Business Science Logo
Read in data and print to HTML. Notice effect of df_print: paged option for HTML.
Try changing to df_print: default, or kable or tibble. PDF prints normally.
Try changing results = "hide".
bike_orderlines_tbl <- read_rds(path = "../00_data/bike_sales/data_wrangled/bike_orderlines.rds")
bike_orderlines_tblWe can do data manipulations too. Try changing the YAML code_folding option from none to hide to show.
Plotting works as expected. Try changin:
out.height, out.width and Knitting
Potential gotcha - Interactive plots (e.g. plotly) will not display in PDF
Static Plots:
ggplot2.g <- revenue_by_category_tbl %>%
ggplot(aes(category_2, total_revenue, fill = category_1)) +
# Geoms
geom_col() +
coord_flip() +
# Formatting
scale_fill_tq() +
scale_y_continuous(labels = scales::dollar_format(scale = 1e-6, suffix = "M")) +
theme_tq() +
labs(
title = "Total Revenue by Category",
x = "", y = "", fill = ""
)
gRevenue by Category
Interactive plots:
ggplotly().Static Tables:
knitr package - knitr::kable() - Simple to use, great with PDFgt package - Not on CRAN yet, but really good for static tablestable_formatted_tbl <- revenue_by_category_tbl %>%
mutate(total_revenue = scales::dollar(total_revenue)) %>%
rename_all(.funs = ~ str_replace(., "_", " ") %>%
str_to_title())
table_formatted_tbl %>% knitr::kable()| Category 2 | Category 1 | Total Revenue |
|---|---|---|
| Cross Country Race | Mountain | $19,224,630 |
| Elite Road | Road | $15,334,665 |
| Endurance Road | Road | $10,381,060 |
| Trail | Mountain | $9,373,460 |
| Over Mountain | Mountain | $7,571,270 |
| Triathalon | Road | $4,053,750 |
| Cyclocross | Road | $2,108,120 |
| Sport | Mountain | $1,932,755 |
| Fat Bike | Mountain | $1,052,620 |
Dynamic Tables:
df_print: paged option in YAML